/**
 * 详情页面
 */
$().ready(function() {
    validateRule();

    layui.use('laydate', function() {
        var laydate = layui.laydate;
    });
});

$.validator.setDefaults({
    submitHandler : function() {
        update();
    }
});
function update() {
	var url = ctx +"module/parameter/" + ($('#signupForm').find("#id").val() == '' ? "save" : "update");

    $.ajax({
        cache : true,
        type : "POST",
        url : url,
        data : $('#signupForm').serialize(),// 你的formid
        async : false,
        error : function(request) {
            parent.layer.alert("Connection error");
        },
        success : function(data) {
            if (data.code == 0) {
                parent.layer.msg("操作成功");
                parent.reLoad();
                var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
                parent.layer.close(index);

            } else {
                parent.layer.alert(data.msg)
            }

        }
    });
}
function validateRule() {
    var icon = "<i class='fa fa-times-circle'></i> ";
    $("#signupForm").validate({
        rules : {
            cardNumber : {
                required : true
            },
            password : {
                required : true
            },
            mobile : {
                required : true,
                isTel : true
            },
            residueTimes : {
                required : true,
                number : true,
                isIntGteZero : true
            }
        },
        messages : {
            vipCardNo : {
                required : icon + "请输入会员卡号索引"
            },
            appId : {
                required : icon + "请输入小程序AppId"
            },
            appSecret : {
                required : icon + "请输入小程序AppSecret"
            },
            mchId : {
                required : icon + "请输入微信支付商户号"
            },
            mchKey : {
                required : icon + "请输入微信支付商户Key"
            },
            notifyUrl : {
                required : icon + "请输入支付回调地址前缀"
            },
            imgUrl : {
                required : icon + "请输入图片地址前缀"
            }
        }
    })
}